package _01_排序;

import _01_排序.tools.Asserts;
import _01_排序.tools.Integers;
import org.junit.Test;

import java.util.Arrays;

@SuppressWarnings("unchecked")
public class CoinChange {
    public static void main(String[] args) {
        Integer[] array = Integers.random(30000,1,30000);

        /*Integer[] nums = {2,4,6,8,10};
        Asserts.test(BinarySearch.search(nums,4) == 2);
        Asserts.test(BinarySearch.search(nums,8) == 4);
        Asserts.test(BinarySearch.search(nums,10) == 5);
        Asserts.test(BinarySearch.search(nums,56) == 5);*/

        sort(array,new BubbleSort01<Integer>(),
                new SelectionSort02<Integer>(),
                new HeapSort03<Integer>(),
                new InsertionSort04<Integer>(),
                new MergeSort05<Integer>(),
                new QuickSort06<Integer>(),
                new ShellSort07<Integer>(),
                new CountingSort08(),
                new RadixSort09());
        //Integers.println(array3);
    }

    static void sort(Integer[] array,Sort... sorts){
        for (Sort sort : sorts) {
            Integer[] newArray = Integers.copy(array);
            //调用父类方法去排序
            sort.sort(newArray);
            Asserts.test(Integers.isAscOrder(newArray)); //是否是升序排列
        }
        Arrays.sort(sorts);
        for (Sort sort : sorts) {
            System.out.println(sort);
        }
    }

    @Test
    public void testHeapSort(){
        Integer[] array = Integers.random(20,1,50);
        new HeapSort03<Integer>().sort(array);
        Integers.println(array);
    }

    @Test
    public void testSelectionSort(){
        Integer[] array = Integers.random(20,1,50);
        new SelectionSort02<Integer>().sort(array);
        Integers.println(array);
    }
}
